export function getFileExt(str:string, truncate = true, withDot = false):string{
    var parts = str.split('.');
    if(parts.length==1){
        return "???";
    }
    var ext = parts[parts.length-1];
    if(truncate){
        if(ext.length>4){
        ext = ext.substring(0,4);
        }
    }
    if(withDot){
        return '.'+ext;
    }
    return ext;
}
export function fileNameWithoutExt(str:string):string{
    return str.replace(/\.[^/.]+$/, "")
}
export function fileNameTruncateKeepingExt(str:string, maxLength:number = 10){
    if(str.length <= maxLength){
        return str
    }
    const displayNameWithoutExt = fileNameWithoutExt(str)
    const displayNameExt = getFileExt(str, true)
    const extLength = displayNameExt.length
    const nameTruncated = displayNameWithoutExt.substring(0, maxLength-extLength-1)+'...'+displayNameExt
    return nameTruncated
}